<template>
	<view class="">
		<view class=" _w-max _top _left _z-index-2 _top _left _over-hid _white-bg" style="position: sticky;" >
			<view class="_w-max _pos-rel _z-index-1"  :style="{height:recHeight}"></view><!-- 状态栏占位盒 -->
			<view class="_w-max _pos-rel _z-index-1  _font-14 _flex-row-center-mid " style="height: 88rpx;">
				<view>{{title}}</view><view @click="goBack" class="iconfont icon-xiangzuo _pad-x-15 _pad-y-10 _pos-abs _left" style="font-size: 30rpx;"></view>
			</view>
			<view class="_w-max _h-220 _pos-abs _top _left"></view>
		</view>
		<view class="_pad-15" v-html="content"></view>
	</view>
</template>

<script>
	import { getArticleDetails } from '@/api/api.js';
	export default{
		data(){
			return{
				id:0,
				articleInfo: [],
				store_info: {},
				content: '',
				shareInfoStatus: false,
				tagStyle: {
					img: 'width:100%;'
				},
				title:'',
				recHeight: '',//状态栏高度
			};
		},
		onLoad(options){
			this.getPhoneInfo();
			if (options.hasOwnProperty('id')) {
				this.id = options.id;
			} else {
				// #ifndef H5
				uni.navigateBack({
					delta: 1
				});
				// #endif
				// #ifdef H5
				history.back();
				// #endif
			}
		},
		onShow: function() {
			this.getArticleOne();
		},
		methods:{
			// 获取顶部高度信息
			getPhoneInfo(){
				let that = this;
				uni.getSystemInfo({
					success(res) {
						that.recHeight = res.statusBarHeight + 'px'; //获取手机状态栏高度
					}												
				});
			},
			//返回
			goBack(){
				let pages = getCurrentPages();
				if(pages.length == 1){
					uni.reLaunch({
						url:'/pages/car_index/index',
						fail(){uni.switchTab({url:'/pages/car_index/index'})}
					})
				}else{
					uni.navigateBack();
				}
			},
			getArticleOne() {
				let that = this;
				getArticleDetails(that.id).then(res => {
					that.title = res.data.title;
					that.$set(that, 'articleInfo', res.data);
					that.$set(that, 'store_info', res.data.store_info ? res.data.store_info : {});
					that.content = res.data.content;
					// #ifdef H5
					if (this.$wechat.isWeixin()) {
						this.setShareInfo();
					}
					// #endif
				});
			},
		},
	}
</script>

<style scoped lang="scss">
</style>